import { defineStore } from "pinia";
import { Names } from "../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { Apis } from "@/api/frontend/index";
import { useUserInfo } from "@/store/userInfo";
import { type } from "os";
import { resolve } from "path";
import { reject } from "lodash";

type S = {
  days: string[];
  times: number[];
};
type codeType = {
  msg: string;
  img: string;
  code: number;
  captchaEnabled: boolean;
  uuid: string;
};
// 前台用户中心主要功能
export const useFrontEnd = defineStore(Names.frontend, {
  state: () => {
    return {
      data: {
        //overview所需数据
        days: [
          "2022-10-14",
          "2022-10-15",
          "2022-10-16",
          "2022-10-17",
          "2022-10-18",
          "2022-10-19",
          "2022-10-20",
        ],
        times: [5, 5, 2, 1, 3, 3, 3],
      },
    };
  },
  getters: {},
  actions: {
    //overView页面相关echarts图表数据
    overViewEcharts() {
      //在这里获取用户账户概览信息
      return new Promise<S>((resolve, reject) => {
        resolve(this.data);
      });
    },
    //获取图形验证码
    getLogincode() {
      return new Promise<codeType>((resolve, reject) => {
        _get(Apis.Logincode, {}, "json", "").then((res: any) => {
          console.log("获取验证码", res);
          resolve(res);
        });
      });
    },
    //登录设备管理平台注销
    logoutAdmin(data: object = {}) {
      return new Promise((resolve, reject) => {});
    },
  },
});
